"""
python操作MySQL
"""
import pymysql
# 连接MySQL数据库
conn = pymysql.connect(
    host='localhost',
    user='root',
    password='111246',
)

# print(conn.get_server_info())
# 创建游标
cursor = conn.cursor()
# 创建数据库
cursor.execute("create database if not exists test")
# 选择数据库
conn.select_db("world")
# 创建数据表
cursor.execute(
    'create table if not exists student(id int, name varchar(20), age int)'
)
cursor.execute('select * from student order by id')

result = cursor.fetchall()
print(cursor.fetchall())
for row in result:
    print(row)